package com.ld.security.common.quartz.modules.job.api;

import com.ld.security.common.core.base.po.PagePo;
import com.ld.security.common.core.base.vo.DataVo;
import com.ld.security.common.core.base.vo.PageVo;
import com.ld.security.common.core.util.StringUtil;
import com.ld.security.common.quartz.modules.job.entity.JobTask;
import com.ld.security.common.tomcat.base.api.SuperApi;
import com.ld.security.common.tomcat.util.AppUtil;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/jobTask")
@Api(tags = "定时任务")
public class JobTaskApi extends SuperApi<JobTask> {

    @Override
    public DataVo<PageVo<JobTask>> page(@RequestBody PagePo<JobTask> po) {
        JobTask q =  po.getQuery();
        if(q == null){
            q = this.newInstance();
        }
        if(StringUtil.isNull(q.getAppName())){
            q.setAppName(AppUtil.getAppName());
        }
        return super.page(po);
    }

    @Override
    public DataVo<PageVo<JobTask>> select(@RequestBody PagePo<JobTask> po) {
        JobTask q =  po.getQuery();
        if(q == null){
            q = this.newInstance();
        }
        if(StringUtil.isNull(q.getAppName())){
            q.setAppName(AppUtil.getAppName());
        }
        return super.select(po);
    }
}
